{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "4\n",
      "deque([1, 2, 3, 5, 6])\n"
     ]
    }
   ],
   "source": [
    "## 用来处理已排序的序列，用来维持已排序的序列，升序\n",
    "## 二分查找\n",
    "\n",
    "import bisect\n",
    "from collections import deque\n",
    "\n",
    "# inter_list = []\n",
    "inter_list = deque()\n",
    "bisect.insort(inter_list, 3)\n",
    "bisect.insort(inter_list, 2)\n",
    "bisect.insort(inter_list, 5)\n",
    "bisect.insort(inter_list, 1)\n",
    "bisect.insort(inter_list, 6)\n",
    "\n",
    "# 二分查找\n",
    "print(bisect.bisect(inter_list, 5))\n",
    "print(inter_list)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
